<template>
  <div class="flow-editor-wraper">
    <wh-flow-editor
      :show-json="true"
      :flow-id="flowId"
      :disabled="disabled"
      :base-url="baseUrl"
      :headers="headers"
      @on-back="onBack"
      @on-complete="onComplete" />
  </div>
</template>
<script>
// import { whFlowEditor } from '@/components/whFlow/index'
import { whFlowEditor } from 'wh-flow'
export default {
  components: {
    whFlowEditor
  },
  data() {
    return {
      baseUrl: 'http://192.168.20.13:8083',
      headers: {
        Authorization: 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjFmZGYzMmJmLWQ2MzItNDM2Yi1iYzY0LTQ4ZmEzM2JhYmJhNCJ9.bex9Jly6LmjqfFV73h3o08lUlhnmJ_kmSC78DdJTQRmED2OkYU22SvWidSwSbo9Vn5olK_k7sjdwO46wZ0k7yA',
      },
      workData: {},
      flowId: '',
      disabled: false
    }
  },
  mounted() {
    // this.initData()
    this.flowId = this.$route.query.id
    this.disabled = this.$route.query.disabled == '1' || false
  },
  methods: {
    initData () {
      this.workData = {
        id: 1,
        name: '请假审批',
        nodeConfig: {
          nodeName: '发起人',
          type: 0,
          nodeRoleList: []
        }
      }
      // childNode: {
      //   nodeName: '条件路由',
      //   type: 4,
      //   conditionNodes: [
      //     {
      //       nodeName: '长期',
      //       type: 3,
      //       priorityLevel: 1,
      //       conditionMode: 1,
      //       conditionList: [
      //         [
      //           {
      //             label: '请假天数',
      //             field: 'day',
      //             operator: '>',
      //             value: '7'
      //           }
      //         ]
      //       ],
      //       childNode: {
      //         nodeName: '领导审批',
      //         type: 1,
      //         setType: 1,
      //         nodeUserList: [
      //           {
      //             id: '360000197302144442',
      //             name: '何敏'
      //           }
      //         ],
      //         nodeRoleList: [],
      //         examineLevel: 1,
      //         directorLevel: 1,
      //         selectMode: 1,
      //         termAuto: false,
      //         term: 0,
      //         termMode: 1,
      //         examineMode: 1,
      //         directorMode: 0
      //       }
      //     },
      //     {
      //       nodeName: '短期',
      //       type: 3,
      //       priorityLevel: 2,
      //       conditionMode: 1,
      //       conditionList: [],
      //       childNode: {
      //         nodeName: '直接主管审批',
      //         type: 1,
      //         setType: 2,
      //         nodeUserList: [],
      //         nodeRoleList: [],
      //         examineLevel: 1,
      //         directorLevel: 1,
      //         selectMode: 1,
      //         termAuto: false,
      //         term: 0,
      //         termMode: 1,
      //         examineMode: 1,
      //         directorMode: 0
      //       }
      //     }
      //   ],
      //   childNode: {
      //     nodeName: '抄送人',
      //     type: 2,
      //     userSelectFlag: true,
      //     nodeUserList: [
      //       {
      //         id: '220000200908305857',
      //         name: '何秀英'
      //       }
      //     ]
      //   }
      // }
    },
    onBack () {
      console.log("返回")
      this.$router.back()
    },
    onComplete (e) {
      console.log("新增完成")
      this.$router.back()
    }
  },
}
</script>

<style scoped lang="scss">
  .flow-editor-wraper {
    width: 100%;
    height: 100%;
  }
</style>
